<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>IndexedDB Demo</title>
  <link rel="stylesheet" href="./style.css"/>
</head>
<body>
  <div>
    <input id="value" type="text" placeholder="请输入待办事项"/>
    <button id="submit">添加</button>
  </div>
  <div id="list"></div>
  <div>
    <button onclick="filter('all')">显示所有</button>
    <button onclick="filter('completed')">显示已完成</button>
    <button onclick="filter('doing')">显示未完成</button>
    <button onclick="removeAll()">清空</button>
  </div>

  <script src="./main.js"></script>
  <script>
    window.addEventListener('load', function() {
      document.getElementById('submit').addEventListener('click', function() {
        const value = document.getElementById('value').value.trim();
        if (value.length === 0) {
          alert('待办事项不能为空');
        } else {
          add(value);
        }
      });
      filter('all');
    });
  </script>
</body>
</html>